import pymysql
class sql:
    def __init__(self):
        sqlip = '192.168.0.235'
        # sqlport = 3306
        sqlroot =  'root'
        sqlpass =  '123456'
        sqldb = 'tinyshop_v2.4'
        self.con = pymysql.connect(sqlip,sqlroot,sqlpass,sqldb,charset='utf8')
        self.cur = self.con.cursor()
    def sqldelete(self):
        self.cur.execute('delete from %s where %s')
    def sqlselect(self,tablename):
        self.cur.execute('select * from %s'%tablename)
        result = self.cur.fetchall()
        self.con.commit()
        self.con.close()
        return result
    def sqlcount(self,tablename,parm):
        self.cur.execute("select count('name') from %s where name='%s'"%(tablename,parm))
        result = self.cur.fetchall()
        self.con.commit()
        self.con.close()
        return result
    def sqlupdate(self):
        pass
    def sqlinsert(self):
        pass
    def sqlshowtb(self):
        self.cur.execute('show tables')
        result = self.cur.fetchall()
        return result
# a = sql().sqlcount('tiny_goods','T恤')
# print(a[0])